/*
 * @Author: deng-chao
 * @Date: 2022-05-20 18:20:07
 * @LastEditTime: 2022-10-24 15:47:11
 * @Description: 缓存管理
 */
const constant = {
	USER_INFO: 'userInfo',
	TOKEN: "access_token",
	REFRESH_TOKEN: "refresh_token",
	OPEN_ID: "open_id",
};


/*user_info ---- serve*/
const setUserInfo = (data) => {
	uni.setStorage({
		key: constant.USER_INFO,
		data: data
	});
};
const getUserInfo = () => {
	return uni.getStorageSync(constant.USER_INFO);
};
const removeUserInfo = () => {
	uni.removeStorage({
		key: constant.USER_INFO
	});
};
/*user_info ---- end*/

/*access_token ---- serve*/
const setToken = (data) => {
	uni.setStorage({
		key: constant.TOKEN,
		data: data
	});
};
const getToken = () => {
	return uni.getStorageSync(constant.TOKEN);
};
const removeToken = () => {
	uni.removeStorage({
		key: constant.TOKEN
	});
};
/*access_token ---- end*/


/*refresh_token ---- serve*/
const setRefreshToken = (data) => {
	uni.setStorage({
		key: constant.REFRESH_TOKEN,
		data: data
	});
};
const getRefreshToken = () => {
	return uni.getStorageSync(constant.REFRESH_TOKEN);
};
const removeRefreshToken = () => {
	uni.removeStorage({
		key: constant.REFRESH_TOKEN
	});
};
/*refresh_token ---- end*/


/*open_id ---- serve*/
const setOpenId = (data) => {
	uni.setStorage({
		key: constant.OPEN_ID,
		data: data
	});
};
const getOpenId = () => {
	return uni.getStorageSync(constant.OPEN_ID);
};
const removeOpenId = () => {
	uni.removeStorage({
		key: constant.OPEN_ID
	});
};
/*open_id ---- end*/



export {
	setUserInfo,
	getUserInfo,
	removeUserInfo,
	setToken,
	getToken,
	removeToken,
	setRefreshToken,
	getRefreshToken,
	removeRefreshToken,
	setOpenId,
	getOpenId,
	removeOpenId,

};